package de.tum.in.eist.poll.client;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.VerticalPanel;

import de.tum.in.eist.poll.pub.shared.Lecture;

/**
 * This class is used to show the student the statistics
 */
public class StatisticView extends VerticalPanel {
	private Chart chart;
	private Button back = new Button();
	
	/**
	 * Shows the statistics.
	 * 
	 * @param lecture is the lecture to be shown within the statistics.
	 */
	public StatisticView(Lecture lecture){
		chart = new Chart(lecture, 350, 200, 0, null);
		chart.addStyleName("userChart");
		this.add(chart);
		Button update = new Button();
		update.setText("update");
		update.addClickHandler(new ClickHandler() {
			
			@Override
			public void onClick(ClickEvent event) {
				chart.update();
				
			}
		});
		back.setText("Back");
		back.addClickHandler(new ClickHandler() {
			
			@Override
			public void onClick(ClickEvent event) {
				RootPanel root = RootPanel.get("main");
				root.clear();
				root.add(new SelectLectureView());
				RootPanel.get("back").clear();
			}
		});
		//this.add(update);
		RootPanel.get("back").add(back);
		//chart.update();
	}
}
